//
// Created by kode.zhong on 2021/3/6.
//
#include <cassert>

#include "chunk.h"

namespace lox {
template<class VALUE_TYPE>
void Chunk<VALUE_TYPE>::WriteChunk(Byte op_code, size_t line) {
  m_code.push_back(op_code);
  m_lines.push_back(line);
}

template<class VALUE_TYPE>
size_t Chunk<VALUE_TYPE>::Size() const {
  return m_code.size();
}

template<class VALUE_TYPE>
size_t Chunk<VALUE_TYPE>::AddConstants(const VALUE_TYPE &value) {
  m_values.push_back(value);
  return m_values.size() - 1;
}

template<class VALUE_TYPE>
VALUE_TYPE Chunk<VALUE_TYPE>::GetValue(size_t idx) const {
  assert(idx < m_values.size());
  return m_values[idx];
}

template<class VALUE_TYPE>
std::vector<size_t> Chunk<VALUE_TYPE>::GetLines() const {
  return m_lines;
}

template class Chunk<double>;
template class Chunk<int>;
};

